var app = getApp()

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    vertical: {
      type: Boolean,
      value: false
    } ,
    autoplay: {
      type: Boolean,
      value: true
    },
    interval: {
      type: Number,
      value: 3800
    } ,
    duration: {
      type: Number,
      value: 500
    } ,
    isHome: {
      type: Number,
      value: 0, 
      observer: function(newVlaue, oldValue) {
        var height = newVlaue == 0 ? '300rpx' : '420rpx' 
        this.setData({height: height})
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    banners: [
      
    ],
    index: 0,
    width: '100%',
    height: '300rpx',
    activeIndex: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    loadData: function(type){
       var self = this;
       let data = {
         'type': type,
       }
       app.func.Post(false, app.api.pic_settings, data, function (res) {
          self.setData({
            banners: res.banners
          })
          console.log("+++++++++++++++++++",res)
       })
     },
     didSelect: function(e){
       this.didTapImage(e.currentTarget.dataset.idx)        
     },

     didTapImage: function(index) {
       this.triggerEvent("didTapImage", this.data.banners[index].linkUrl)
    },
    setSize: function(width, height) {
      this.setData({
        width: width,
        height: height
      })
    },
    swiperChange: function(e) {
      this.setData({
        activeIndex: e.detail.current
      })
    }         
  }
})
